]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
popupMenu: Add smooth scrolling support for sliders
authorJasper St. Pierre <jstpierre@mecheye.net>
Sun, 4 Nov 2012 15:50:11 +0000 (10:50 -0500)
committerJasper St. Pierre <jstpierre@mecheye.net>
Thu, 20 Dec 2012 13:40:04 +0000 (08:40 -0500)
Allowing smooth scrolling on the Y axis to accurately adjust the value
of the slider.

https://bugzilla.gnome.org/show_bug.cgi?id=687573

js/ui/popupMenu.js

index 239edaf1ade60817c9894e6acdf4cb3ed38b9e37..fd4b9280cad28113aafcd17941ecd6650612e3b7 100644 (file)
@@ -638,14 +638,23 @@ const PopupSliderMenuItem = new Lang.Class({
 
     _onScrollEvent: function (actor, event) {
         let direction = event.get_scroll_direction();
+        let delta;
+
+        if (event.is_pointer_emulated())
+            return;
 
         if (direction == Clutter.ScrollDirection.DOWN) {
-            this._value = Math.max(0, this._value - SLIDER_SCROLL_STEP);
-        }
-        else if (direction == Clutter.ScrollDirection.UP) {
-            this._value = Math.min(1, this._value + SLIDER_SCROLL_STEP);
+            delta = -SLIDER_SCROLL_STEP;
+        } else if (direction == Clutter.ScrollDirection.UP) {
+            delta = +SLIDER_SCROLL_STEP;
+        } else if (direction == Clutter.ScrollDirection.SMOOTH) {
+            let [dx, dy] = event.get_scroll_delta();
+            // Even though the slider is horizontal, use dy to match
+            // the UP/DOWN above.
+            delta = -dy / 10;
         }
 
+        this._value = Math.min(Math.max(0, this._value + delta), 1);
         this._slider.queue_repaint();
         this.emit('value-changed', this._value);
     },